import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:learnfluttersecond/res.dart';
import 'package:learnfluttersecond/widgets/search_bar.dart';
import 'package:learnfluttersecond/widgets/swip_banner.dart';

class CommunityCommerce extends StatefulWidget {
  @override
  _CommunityCommerceState createState() => _CommunityCommerceState();
}

class _CommunityCommerceState extends State<CommunityCommerce> {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Container(
      color: Colors.white,
      child: Column(
        children: <Widget>[
          Container(
            child: Row(
              children: <Widget>[
                Text('首页',
                    style: TextStyle(
                        fontWeight: FontWeight.bold,
                        color: Color(0xFF333333),
                        fontSize: 17))
              ],
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
            ),
            height: 50,
          ),
          buildHeader(),
          SearchBar(
            marginLeft: 15,
            marginRight: 15,
            bgCorlor: Color(0xFFF5F6FA),
            marginTop: 5,
            marginBottom: 5,
            hintText: '请输入你需要的商品',
          ),
          SwipeBanner(
            [
              "https://iph.href.lu/345x150",
              "https://iph.href.lu/345x150",
              "https://iph.href.lu/345x150"
            ],
            height: 115,
          )
        ],
      ),
    ));
  }

  buildHeader() {
    var companyName = Text(
      '历下区历山路齐鲁师范',
      style: TextStyle(
          color: Color(0xFF333333), fontSize: 15, fontWeight: FontWeight.bold),
    );

    var leftAddressIcon = Image.asset(
      Res.dizhiicon,
      width: 16,
      height: 18,
    );

    var rightArrow = Image.asset(
      Res.tiazhuanjin,
      width: 4.5,
      height: 8,
    );
    var wannaInject = Container(
      margin: EdgeInsets.only(right: 15),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Image.asset(
            Res.touOxx,
            width: 27,
            height: 27,
          ),
          Container(
            padding: EdgeInsets.only(left: 5, right: 5, top: 3, bottom: 3),
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10),
                color: Color(0xFFFFEDED)),
            margin: EdgeInsets.only(top: 5),
            child: Text(
              '我要入驻',
              style: TextStyle(fontSize: 10, color: Color(0xFFFF595E)),
            ),
          ),
        ],
      ),
    );
    var row = Row(
      children: <Widget>[
        Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            SizedBox(
              height: 10,
            ),
            Container(
              margin: EdgeInsets.only(left: 15),
              child: Row(
                children: <Widget>[
                  leftAddressIcon,
                  SizedBox(
                    width: 8.5,
                  ),
                  companyName,
                  SizedBox(
                    width: 5,
                  ),
                  rightArrow
                ],
              ),
            ),
            SizedBox(
              height: 10,
            ),
            Container(
              margin: EdgeInsets.only(left: 15),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.start,
                children: <Widget>[
                  Image.asset(
                    Res.fensisihsi,
                    width: 12,
                    height: 12,
                  ),
                  SizedBox(
                    width: 5,
                  ),
                  Text(
                    '粉丝：36598',
                    style: TextStyle(color: Color(0xFFA3A9BB), fontSize: 11),
                  ),
                  SizedBox(
                    width: 10,
                  ),
                  Image.asset(
                    Res.huanuzhua,
                    width: 40.5,
                    height: 16,
                  )
                ],
              ),
            ),
            SizedBox(
              height: 10,
            ),
          ],
        ),
        Expanded(
          child: SizedBox(),
        ),
        GestureDetector(
          child: wannaInject,
          onTap: () {
            print('我要入驻');
          },
        ),
      ],
    );
    return Container(
      child: row,
    );
  }
}
